<?php
require_once("lib/nusoap.php");
require_once("serverFunctions.php");

// set namespace
$ns="http://localhost/";
// create SOAP server object
$server = new soap_server();
$server->soap_defencoding = 'UTF-8'; 
// setup WSDL file, a WSDL file can contain multiple services
$server->configureWSDL('Pharmacy',$ns);
$server->wsdl->schemaTargetNamespace=$ns;

$server->wsdl->addComplexType(
    'pharmacy',
    'complexType',
    'struct',
    'all',
    '',
    array(
        'Name'		=> array('name' => 'Name','type'=>'xsd:string'),
        'Address'	=> array('name' => 'Address', 'type' => 'xsd:string'),
        'Phone'   	=> array('name' => 'Phone', 'type' => 'xsd:string' ),
        'isPharmacy'=> array('name' => 'isPharmacy', 'type' => 'xsd:boolean'),
        'id'		=> array('name' => 'id', 'type' => 'xsd:integer'),
    	'lattitude' => array('name' => 'lattitude', 'type' => 'xsd:double'),
    	'longitude' => array('name' => 'longitude', 'type' => 'xsd:double'),
    	'URL'		=> array('name' => 'URL', 'type' => 'xsd:string')
    )
);
$server->wsdl->addComplexType(
    'pharmaciesArray',
    'complexType',
    'array',
    '',
    'SOAP-ENC:Array',
    array(),
    array(
        array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:pharmacy[]')
    ),
    'tns:pharmacy'
);


$server->register('getElements',
	array('parentId' => 'xsd:integer'), 				// input parameters
	array('getElementsResult' => 'tns:pharmaciesArray'), 	// output parameter
	$ns, 												// namespace
        "$ns#getElements"
	);
$server->register('search',
	array('countyName' => 'xsd:string', 'parentId' => 'xsd:integer' ), 	// input parameters
	array('searchResult' => 'tns:pharmaciesArray'), 					// output parameter
	$ns, 																// namespace
        "$ns#search"
	);
$server->register('searchPlace',
	array('lattitude' => 'xsd:double', 'longitude' => 'xsd:double', 'range' => 'xsd:integer' ),	// input parameters

	array('searchResult' => 'tns:pharmaciesArray'), 					// output parameter
	$ns, 																// namespace
        "$ns#searchPlace"
	);

$HTTP_RAW_POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA'])  ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
$server->service($HTTP_RAW_POST_DATA);

?>